package com.wanmait.wanmarecruit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wanmait.wanmarecruit.entity.ManagerRole;
import com.wanmait.wanmarecruit.mapper.ManagerRoleMapper;
import com.wanmait.wanmarecruit.service.ManageRoleService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.wanmarecruit.entity.ManageRole;
import com.wanmait.wanmarecruit.mapper.ManageRoleMapper;

@Service
public class ManageRoleServiceImpl extends ServiceImpl<ManageRoleMapper, ManageRole> implements ManageRoleService {
    @Resource
    private ManagerRoleMapper managerRoleMapper;
    @Resource
    private ManageRoleMapper manageRoleMapper;

    @Override
    public List<ManageRole> findListByManagerId(Integer id) {
        LambdaQueryWrapper<ManagerRole> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ManagerRole::getManagerId,id);
        List<ManagerRole> managerRoles = managerRoleMapper.selectList(queryWrapper);
        if (managerRoles.size()==0)
        {
            return Collections.emptyList();
        }
        List<Integer> ids = managerRoles.stream().map(managerRole -> managerRole.getRoleId()).collect(Collectors.toList());
        return manageRoleMapper.selectBatchIds(ids);
    }
}
